package com.reny.ll.git.mvvm.view

import android.content.Context
import android.graphics.drawable.AnimationDrawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import com.reny.ll.git.mvvm.R

class StateLoadingView @JvmOverloads constructor(
    context: Context?,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr), IStateView{

    private var stateView: View = LayoutInflater.from(context).inflate(R.layout.view_state_loading, this)
    private var iv_anim:ImageView
    private var tv_loading:TextView

    init {
        iv_anim = stateView.findViewById(R.id.iv_anim)
        tv_loading = stateView.findViewById(R.id.tv_loading)

        (iv_anim.background as AnimationDrawable).start()
    }

    override fun setImg(imgId:Int){
        iv_anim.setImageResource(imgId)
    }

    override fun setTip(tip:String){
        tv_loading.text = tip
    }

    override fun setRetryTip(tip: String) {

    }


}